const {ccclass, property} = cc._decorator;

@ccclass
export default class Help extends cc.Component {
    private layers:cc.Node[] =[]                            //存放三个节点的数组
    private pageTextHelp:cc.Label = null                    //帮助节点下的标签
    private pageTextTower:cc.Label = null                   //炮塔节点下的标签
    private pageViewHelp:cc.PageView = null                 //帮助节点下的翻页容器
    private pageViewTower:cc.PageView = null                //炮塔节点下的翻页容器

    onLoad(){
        this.layers = this.node.getChildByName("layerNode").children
        this.pageTextHelp = cc.find("layerNode/helpNode/pageText_help", this.node).getComponent(cc.Label)
        this.pageTextTower = cc.find("layerNode/towerNode/pageText_tower", this.node).getComponent(cc.Label)
        this.pageViewHelp = cc.find("layerNode/helpNode/help_pageView", this.node).getComponent(cc.PageView)
        this.pageViewTower = cc.find("layerNode/towerNode/tower_pageView", this.node).getComponent(cc.PageView)
    }

    start () {
        
    }

    update (dt) {
        
    }

    onBackHomeClick(){
        cc.director.loadScene("startScene")
    }

    onToggleClick(event, data){
        this.pageViewHelp.setCurrentPageIndex(0)
        this.pageViewTower.setCurrentPageIndex(0)

        for(let i = 0; i < 3; i++){
            if(i == data){
                this.layers[i].active = true;
            }else{
                this.layers[i].active = false;
            }
        }
    }

    onPageViewHelpLienerEvent(){
        this.pageTextHelp.string = `${this.pageViewHelp.getCurrentPageIndex() + 1}  /  4`
    }

    onPageViewTowerLienerEvent(){
        this.pageTextTower.string = `${this.pageViewTower.getCurrentPageIndex() + 1}  /  19`
    }

}
